<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

		<meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1,user-scalable=no">
		<meta name="format-detection" content="telephone=no">
		<title><?php echo $title;?></title>
		<script src="<?php echo base_url('wj/js/hm.js');?>"></script>
		<script type="text/javascript">
			if(window.location.hash) {
				window.location.hash = "";
				window.location.href = window.location.href.replace("#", "");
			}
			var isWeiXin = 0;
		</script>
		<link rel="stylesheet" href="<?php echo base_url('wj/css/jqmobo.css');?>">

		<script src="<?php echo base_url('wj/js/jquery.min.js');?>"></script>
		<script type="text/javascript">
			!window.jQuery && document.write('<script src="/js/mobile/jquery-1.10.1.min.js"><\/script>');
		</script>

<!-- 		<script src="js/hintinfo.js" type="text/javascript"></script> -->
		<script src="<?php echo base_url('wj/js/jqmobo2.js')?>" type="text/javascript"></script>
		<style>

		</style>
	</head>

	<body rlt="1">
		
			<?php if ($exits==0){?>
			 <form id="form1" method="post" action="">
				<div id="divQuestion">
					<fieldset class="fieldset" style="" id="fieldset1">
					 <?php if (!empty($list)){?>
					   <?php foreach ($list as $k=>$v){?>
						    <?php if ($v['qsort']==0){?>
							<div class="field ui-field-contain" id="div<?php echo $v['id'];?>" req="1" topic="<?php echo $v['id'];?>" data-role="fieldcontain" type="3">
								<div class="field-label">
									<?php echo $v['id'].'、'.$v['title'];?><span class="req">*</span>
								</div>
								<div class="ui-controlgroup">
								<!--选项 -->
								  <?php if (!empty($v['answer'])){?>
									  	<?php foreach ($v['answer'] as $kk=>$vv){?>
											<div class="ui-radio">
											    <span class="jqradiowrapper">
											    <?php if ( $kk=='a_1'){//选中?>
											      <input checked="checked" type="radio" value="<?php echo $vv['a_id'];?>" id="<?php echo 'q'.$v['id'].'_'.$vv['a_id'];?>" name="<?php echo 'q'.$v['id'];?>" style="display:none;">
											      <a class="jqradio jqchecked" href="javascript:;"></a>
											    <?php }else{//未选中?>
											      <input type="radio" value="<?php echo $vv['a_id'];?>" id="<?php echo 'q'.$v['id'].'_'.$vv['a_id'];?>" name="<?php echo 'q'.$v['id'];?>" style="display:none;">
											      <a class="jqradio" href="javascript:;"></a>
											    <?php }?>
											    </span>
												<div class="label" for="<?php echo 'q'.$v['id'].'_'.$vv['a_id'];?>"><?php echo $vv['name'];?></div>
											</div>
										<?php }?>
									<?php }?>
								<!--选项end -->
								</div>
								<div class="errorMessage"></div>
								</div>
							<?php } else if ($v['qsort']==1){//复选框类型?>
								<div class="field ui-field-contain" id="div<?php echo $v['id'];?>" req="1" topic="<?php echo $v['id'];?>" minvalue="1" <?php if ($v['qlimit']>0){echo 'maxvalue="'.$v['qlimit'].'"';}?> data-role="fieldcontain" type="4">
									<div class="field-label">
										<?php echo $v['id'].'、'.$v['title'];?>
										<span class="req">*</span>
										<span class="qtypetip">&nbsp;<?php echo ($v['qlimit']>0)?"[请选择<b>1</b>-<b>{$v['qlimit']}</b>项]":'[多选题]';?></span>
									</div>
									<div class="ui-controlgroup">
									<!--选项 -->
								    <?php if (!empty($v['answer'])){?>
									  	<?php foreach ($v['answer'] as $kk=>$vv){?>
										<div class="ui-checkbox">
										   <span class="jqcheckwrapper">
										    <input type="checkbox" value="<?php echo $vv['a_id'];?>" id="<?php echo 'q'.$v['id'].'_'.$vv['a_id'];?>" name="<?php echo 'q'.$v['id'].'[]';?>" style="display:none;" <?php if(!empty($vv['extra']) && ($vv['extra']==1)){echo 'extra="1"';} ?>>
										    <a class="jqcheck" href="javascript:;"></a>
										   </span>
										   <div class="label" for="<?php echo 'q'.$v['id'].'_'.$vv['a_id'];?>"><?php echo $vv['name'];?></div>
										   <?php if ( !empty($vv['extra'])&& ($vv['extra']==1) ){?>   
										   <div class="ui-text"><input checked="checked" type="text" rel="<?php echo 'q'.$v['id'].'_'.$vv['a_id'];?>" id="<?php echo 'tqq'.$v['id'].'_'.$vv['a_id'];?>" class="OtherText"></div><br>
										   <?php }?>
										</div>
										<?php }?>
									<?php }?>
								   <!--选项end -->
									</div>
									<div class="errorMessage"></div>
								</div>
							<?php }elseif ($v['qsort']==2){//输入框类型?>
								<div class="field ui-field-contain" id="div<?php echo $v['id'];?>" req="1" topic="<?php echo $v['id'];?>" data-role="fieldcontain" type="5">
									<div class="field-label">
										<?php echo $v['id'].'、'.$v['title'];?>
										<span class="req">*</span>
									</div>
									<div class="ui-controlgroup">
										<div class="ui-input-text">
											<input type="textarea" class="OtherText" name="<?php echo 'q'.$v['id'];?>">
										</div>
									</div>
									<div class="errorMessage"></div>
							   </div>
							<?php }?>
						<?php }?>
					<?php }?>
						<div class="errorMessage" id="divError"></div>
					</fieldset>
				</div>
				
				<div id="divMatrixRel" style="position: absolute; display: none; width: 80%; margin: 0 10%;" class="ui-input-text">
					<input type="text" placeholder="" id="matrixinput" style="min-height: 2em;
                width: 100%; padding: 0.3em 0.6em;">
				</div>
				
				<div class="shopcart" id="shopcart" style="display:none;">
				</div>
				<div class="footer">
					<div class="ValError">
					</div>
					<div id="divSubmit" style="padding: 10px;">
						<a id="wj_sub" href="javascript:;" class="button blue">提交</a>
<!-- 							<input class="button blue" type="submit" value="提交"> -->
						<div style="margin:0px 0 10px; padding-top:10px;">
						</div>
					</div>
				</div>
				</form>
				<?php }elseif ($exits==1){?>
					 <div style="text-align:center;margin-top:-87px;height:175px;width:92%;position:fixed;top:50%;left:4%;">
					    <img style="vertical-align:middle;height:122px;width:122px;" src="<?php echo base_url('wj/images/ganxie.png');?>" alt="" />
					    <h4 style="color:#06c1ae;text-align:center;margin-top:30px" >您已完成此次问卷调查，非常感谢您的参与!</h4>
					 </div>
				<?php }else{?>
					<div style="text-align:center;margin-top:-87px;height:175px;width:92%;position:fixed;top:50%;left:4%;">
						<img style="vertical-align:middle;height:122px;width:122px;" src="<?php echo base_url('wj/images/ganxie.png');?>" alt="" />
					    <h4 style="color:#06c1ae;text-align:center;margin-top:30px">请先登录！</h4>
					</div>
				<?php }?>
				
			<div id="cg">
			</div>
			
			<div id="divPowerBy" style="margin-top:100px;" class="logofooter">
				
			</div>
		
		<script type="text/javascript">
			$(function(){
				$('#wj_sub').click(function(){
					//检查表单值
					if(checkVal()){
						var pdata = $('#form1').serialize();
						$.ajax({
			                type: "POST",
			                url:'',
			                data: pdata,// 你的formid
			                dataType: "json",
			                success: function(data) {
				                if(data.error =='-1'){
				                	$("#divError .errorMessage").html(data.msg);
					                return false;
					            }else{
						            $("#form1").hide();
						            var img_src = "<?php echo base_url('wj/images/ganxie.png');?>";
						            var cg_str ='<div style="text-align:center;margin-top:-87px;height:175px;width:92%;position:fixed;top:50%;left:4%;"><img style="vertical-align:middle;height:122px;width:122px;" src="'+img_src+'" alt="" /><h4 style="color:#06c1ae;text-align:center;margin-top:30px" >您已完成此次问卷调查，非常感谢您的参与!</h4></div>';
						            $("#cg").html(cg_str);
					            	//window.location.reload();
					            	return false; 
							    }
			                },
							error: function(request) {
								$("#divError .errorMessage").html("网络错误,请稍后再试！");
			                    return false;
			                }
			            });
					}else{
						//alert('您的问题还未答完哟！');
						return false;
					}
				});
				
				function checkVal(){
					var count = <?php echo count($list);?>;
					 for( var i=1;i<=count;i++ ){
						var d_name = "#div"+i;
						var i_type = $(d_name).attr('type');
						var i_name = '';
						
						if(i_type ==3){
							i_name = 'radio';	
						}else if (i_type ==4){
							i_name = 'checkbox';
					    }else{
					    	i_name = 'textarea';
						}
						
						if( i_name == 'textarea'){
							$res = $("#div"+i+" input[type='"+i_name+"']").val();
							if($res ==''){
								$("#div"+i+" .errorMessage").html('这题也要答哟！');
								$('html, body').animate({  
				                    scrollTop: $("#div"+i).offset().top  
				                }, 10);
				                return false;
							}else{
							    continue;
							}
						}else{
							 var len = $("#div"+i+" input[type='"+i_name+"']").size();
							    var j=0;
								$("#div"+i+" input[type='"+i_name+"']").each(function(){
								   var res_check = $(this).is(':checked');
								   if( res_check== false){
										j++;	
									}else{
										if($(this).attr('extra') == 1){
											var o_id = $(this).attr('id').replace('q'+i+'_',"");
											var extra_id = 'tq'+$(this).attr('id');
											var extra_val = $('#'+extra_id).val();
											if( ("undefined" != typeof extra_val) && (extra_val != '')){
												var n_val = '{"id":'+o_id+',"text":"'+extra_val+'"}';
												$(this).val('');
												$(this).val(n_val);
											}
											if( extra_val =='' ){
												$(this).val('');
												$(this).val(o_id);
											}
										}
									}
								});
								if( j==len ){
									$("#div"+i+" .errorMessage").html('请选择一项吧！');
									$('html, body').animate({  
					                    scrollTop: $("#div"+i).offset().top  
					                }, 10);
									return false;
								}else{
									continue;
								}
						}
					 }	
					 return true;
				}	

			});
			
		</script>
		
		<script type="text/javascript">
			var activityId = 13539507;
			var isYdb = 0;
			var isPub = 0;
			var cqType = 1;
			var isDingDing = 0;
			var ddcorpid = "";
			var sojumpParm = '';
			var isKaoShi = 0;
			var lastTopic = 0;
			var Password = "";
			var guid = "";
			var udsid = 0;
			var langVer = 0;
			var cProvince = "";
			var cCity = "";
			var cIp = "";
			var divTip = document.getElementById("divTip");
			var displayPrevPage = "none";
			var inviteid = '';
			var access_token = "";
			var openid = "";
			var isQQLogin = 0;
			var wxthird = 0;
			var hashb = 0;
			var sjUser = '';
			var outuser = '';
			var outsign = '';
			var sourceurl = '';
			var sourcename = "";
			var isSimple = '';
			var jiFenBao = 0;
			var cAlipayAccount = "";
			var isRunning = 1;
			var SJBack = '';
			var jiFen = "0";
			var ItemDicData = "";
			var rndnum = "1034326058.27166794";
			var totalPage = 1;
			var totalCut = 0;
			var cepingCandidate = "";
			var cpid = "";
			var needSaveJoin = 0;
			var qBeginDate = "1492686221580";
			var randomMode = 0;
			var fisrtLoadTime = new Date().getTime();
		</script>

		<script type="text/javascript">
			var needAvoidCrack = 0;
			var tdCode = "tdCode";
			var imgCode = $("#imgCode")[0];
			var submit_text = $("#yucinput")[0];
			var tCode = $("#" + tdCode)[0];
			var hasTouPiao = 0;
		</script>

	</body>

</html>